<template>
	<view>
		<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" collection="category" :getone="true"
			:where="where" manual="true">
			<view v-if="error">{{error.message}}</view>
			<view v-if="loading" class="loading-simple">加载中...</view>
			<view v-else>
				<view>名称：{{data.name}}</view>
				<textarea v-if="data.describe" :value="data.describe" disabled />
			</view>
		</unicloud-db>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				_id: '',
				where: ''
			};
		},
		onLoad(e) {
			const id = e.id
			if (id) {
				this._id = id
				this.where = "_id == '" + this._id + "'"

			} else {
				uni.showModal({
					content: "页面参数错误",
					showCancel: false
				})
			}
		},
		onReady() {
			if (this._id) {
				this.$refs.udb.loadData()
			}
		}
	}
</script>

<style lang="scss">
	.loading-simple {
		text-align: center;
		margin: 100px;
		color: #555555;
	}

	textarea {
		border: 1px solid grey;
		width: 100%;
	}
</style>